package homework.akkademo;

import akka.actor.UntypedAbstractActor;
import akka.event.Logging;
import akka.event.LoggingAdapter;

public class MyAkka extends UntypedAbstractActor {

    LoggingAdapter log = Logging.getLogger(this.getContext().getSystem(), this);

    /**
     * 用于接收并处理新消息
     * @param message
     * @throws Throwable
     */
    @Override
    public void onReceive(Object message) throws Throwable {
        if (message instanceof String) {
            log.info(message.toString());
            log.info("发送者是：{}", getSender());
        } else {
            // 无法匹配到类型
            unhandled(message);
        }
    }
}
